package org.msfj.hospital.api;

import com.github.pagehelper.PageInfo;
import org.msfj.common.model.CommonResult;
import org.msfj.hospital.model.HospitalDept;
import org.msfj.hospital.service.HospitalDeptService;
import org.msfj.hospital.vo.HospitalDeptVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 医院科室接口
 * @User: Administrator
 * @Date: 2018/8/19 0019
 */
@RestController
@RequestMapping("api/hospital")
public class HospitalDeptApiController {
    @Autowired
    HospitalDeptService hospitalDeptService;

    /**
     * 根据vo查询医院科室列表
     *
     * @param hospitalDeptVo
     * @param page
     * @param rows
     * @return
     */
    @GetMapping("/listHospitalDeptByVo")
    public CommonResult<PageInfo<HospitalDeptVo>> listHospitalDeptByVo(HospitalDeptVo hospitalDeptVo, Integer page, Integer rows) {
        PageInfo<HospitalDeptVo> hospitalDeptVoPageInfo = hospitalDeptService.getByHospitalDept(hospitalDeptVo, page, rows);
        return CommonResult.ok(hospitalDeptVoPageInfo);
    }

    /**
     * 根据id查询医院科室对象
     *
     * @param id
     * @return
     */
    @GetMapping("/getHospitalDeptById")
    public CommonResult<HospitalDeptVo> getHospitalDeptById(String id) {
        HospitalDept byId = hospitalDeptService.getById(id);
        return CommonResult.ok(byId);
    }
}
